/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package cart.hibernate.rating;

/**
 *
 * @author BibooChung
 */
import cart.hibernate.movieInformation.*;

public class Rating {
    private long movieId;
    private double avgRate;
    private long numOfRate;

    private MovieInformation movie;

    public Rating(){
    }

    public Rating(double avgRate, long numOfRate){
            this.avgRate = avgRate;
            this.numOfRate = numOfRate;
    }

    public Rating(Rating rating){
        this.avgRate = rating.getAvgRate();
        this.numOfRate = rating.getNumOfRate();
    }

    public long getMovieId(){
        return movieId;
    }
    /**
     * Getter of avgRate
     * @return this.avgRate
     */
    public double getAvgRate(){
        return avgRate;
    }

    public long getNumOfRate(){
        return numOfRate;
    }

    public MovieInformation getMovie(){
     //   MovieInformation newMovie = new MovieInformation(movie);
     //   return newMovie;
        return movie;
    }
    
    /**
     * Setter of movieId
     * @param id set movieId to id's value
     */
    public void setMovieId(long id) {
        this.movieId = id;
    }
    /**
     * Setter of avgRate
     * @param avgRate set avgRate to avgRate's value
     */
    public void setAvgRate(double avgRate){
        this.avgRate = avgRate;
    }

    public void setNumOfRate(long numOfRate){
        this.numOfRate = numOfRate;
    }

    public void setMovie(MovieInformation movie){
      //  this.movie = new MovieInformation(movie);
        this.movie = movie;
    }

    public void setRating(double avgRate, long numOfRate){
        this.avgRate = avgRate;
        this.numOfRate = numOfRate;
    }

    public void setRating(double avgRate, long numOfRate, MovieInformation movie){
        this.avgRate = avgRate;
        this.numOfRate = numOfRate;
        this.movie = movie;
        //this.movie = new MovieInformation(movie);
    }

    public void addRate(double newRate){
        this.numOfRate++;
        this.avgRate = (avgRate + newRate) / numOfRate;
    }
}
